{{ define "main" }}
<style> 
  table,table tr th, table tr td { 
      border:1px solid #eee; 
  }
  table { 
      text-align: center; 
      border-collapse: collapse;
      margin: 0 auto;
  }
  .content {
      margin: 20px auto;
      max-width: 1200px;
      background: #fff;
      padding: 20px;
  }
  h3 {
    text-align: center;  
  }
  thead tr th {
    line-height: 40px;
  }
  a {
    text-decoration: none;
    color: #0594cb;
  }
</style>
{{ range (.Pages.GroupByParam "year").Reverse }}
<div style="background: #f5f5f5">
<div class="content">
  <h3>{{.Key}}年度计划安排</h3>
  <table width="1000px">
    <thead>
      <tr>
        <th>城市</th>
        <th>主题/日期</th>
        <th>位置</th>
        <th>状态</th>
        <th>赞助</th>
      </tr>
    </thead>
    <tbody>
      <!-- should use hostDate instead of order, but cannot get the right order by hostDate -->
      {{ range (sort .Pages ".Params.order" "desc") }}
      <tr>
        <td>{{ .Params.city }}</td>
        <td>
          {{ with .Params.topic }}{{ . }}{{ else }}待定{{ end }}</br>
          {{ with .Params.hostDate }}{{ . }}{{ else }}待定{{ end }}
        </td>
        <td>
          {{ if ne .Params.location "" }}
          {{ if ne .Params.map "" }}<a target="_blank" href="{{.Params.map}}">{{.Params.location}}</a>{{else}}{{.Params.location}}{{ end }}
          {{else}}待定{{end}}
        </td>
        <td>
          {{ $link := .RelPermalink }}
          {{with .Params.status}}<a href="{{ $link }}">{{.}}</a>{{else}}敬请期待{{end}}
        </td>
        <td>
          {{with .Params.sponsors}}
            {{ range . }}
            <img src="/images/sponsors/{{.}}.png">
            {{ end }}
          {{else}}
          <a href="mailto:admin@mail.jenkins-zh.cn?subject=活动-{{.Params.topic}}-赞助"
            class="f6 ph3 pv1 br2 dib  tc ttu mv3 bg-primary-color white hover-bg-green link"
            target="_blank">
            立即申请
          </a>
          {{end}}
        </td>
      </tr>
      {{ end }}
    </tbody>
  </table>
</div>
</div>
{{end}}
{{end}}
